using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace DigitalTrainSuite.UserControls
{
	public partial class UserControlAnyTrainController : UserControl
	{

		public Color TrainColor
		{
			get
			{
				return this.BackColor;
			}
			set
			{
				this.userControlTrainContoller.BackColor = value;
				this.BackColor = value;
			}
		}

		public DataSetLayout Data
		{
			set
			{
				this.dataSetLayout = value;
				this.bindingSourceTrain.DataSource = this.dataSetLayout;
				this.userControlTrainContoller.Enabled = true;
				this.userControlTrainContoller.LocoID = Convert.ToInt32(this.comboBoxTrainSelector.SelectedValue);
				try
				{
					this.userControlTrainContoller.LocoName = this.dataSetLayout.Train.findByLocoAddress((int)this.comboBoxTrainSelector.SelectedValue).name;
				}
				catch { }
			}
		}

		public UserControlAnyTrainController()
		{
			InitializeComponent();
		}

		public void addControlLocomotive(ControlLocomotive controlLocomotive)
		{
			this.userControlTrainContoller.controlLocomotive += new ControlLocomotive(controlLocomotive);
		}

		private void comboBoxTrainSelector_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.userControlTrainContoller.Enabled = true;
			this.userControlTrainContoller.LocoID = Convert.ToInt32(this.comboBoxTrainSelector.SelectedValue);
			try
			{
				this.userControlTrainContoller.LocoName = this.dataSetLayout.Train.findByLocoAddress((int)this.comboBoxTrainSelector.SelectedValue).name;
			}
			catch { }
		}
	}
}
